package muilty_thread.java_current_practice_and_kernel.cp6;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.*;

public class Renderer {
    private final ExecutorService exec = Executors.newFixedThreadPool(100);

    void renderPage() throws InterruptedException, ExecutionException {
        List<ImageInfo> list = new ArrayList<>();
        CompletionService<Integer> completionService = new ExecutorCompletionService<>(exec);
        for (int i = 0; i < 10; i++) {
            completionService.submit(() ->{
                System.out.println(new Random().nextInt());
                return new Random().nextInt();
            });
        }

        for (int i = 0; i < 10; i++) {
            Future<Integer> take = completionService.take();
            Integer integer = take.get();
            System.out.println(integer);
        }
    }


    public static void main(String[] args) throws ExecutionException, InterruptedException {
       /* Renderer renderer = new Renderer();
        renderer.renderPage();*/


        try{
            while (true) {

            }
        }finally {
            System.out.println("123213213");
        }

    }

}

class ImageInfo{

}